const Controller = require('egg').Controller;

class UserController extends Controller {
  async index() {
    const users = await this.ctx.model.User.findAll();
    this.ctx.body = users;
  }

  async create() {
    const { name, age } = this.ctx.request.body;
    const user = await this.ctx.model.User.create({ name, age });
    this.ctx.body = user;
  }
}

module.exports = UserController; 